package io.renren.modules.commonproblem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.commonproblem.dao.ProblemMapper;
import io.renren.modules.commonproblem.entity.Problem;
import io.renren.modules.commonproblem.service.ProblemService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> implements ProblemService {
    @Override
    public PageUtils findProblemList(Map<String, Object> params) {
        LambdaQueryWrapper<Problem> wrapper = new LambdaQueryWrapper<>();
        String name = (String) params.get("name");
        if (StringUtils.isNotBlank(name)){
            wrapper.like(Problem::getProblemTitle,name);
        }
        IPage<Problem> page = page(new Query<Problem>().getPage(params),wrapper );
        return new PageUtils(page);
    }

}
